﻿@model WebUI.Models.Recuper
<style type="text/css">
    table.thistable tr td {
        padding-top: 0px;
        padding-bottom: 0px;
    }

    #AttachInfoContainer {
        padding: 10px;
    }

    .tabheader a {
        min-width: 80px;
        padding: 4px;
        margin: 1px;
        background-color: #f19149;
        border: 1px solid #f1f1f1;
        color: White;
        white-space: nowrap;
        text-decoration: none;
        line-height: 24px;
    }
</style>
@using (Ajax.BeginForm(new AjaxOptions()
{
    LoadingElementId = "OnLoadingSpan",
    UpdateTargetId = "dialogbox",
    InsertionMode = InsertionMode.Replace,
    HttpMethod = "Post",
    OnSuccess = "alert('保存成功，可以继续编辑或关闭退出编辑。')",
    OnFailure = "OnSiteError"
            ,
    OnBegin = "$('#submit').fadeOut(500)"
        ,
    OnComplete = "$('#submit').fadeIn(1000)"
}))
{
    //$('#dialogbox').dialog('close');建议切换前保存修改
    @Html.ValidationSummary(true)
    <table class="width noborder tabheader" title="切换前请一定注意是否有未保存数。">
        <tr>
            <td width="64" nowrap="nowrap" valign="top">
                @Ajax.ActionLink("基本信息", "RecuperEdit", new { ID = Model.User.UserId }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "dialogbox", Confirm = "" })
            </td>
            <td valign="top" nowrap="nowrap">
                @{var i = 0;}
                @foreach (var rec in Model.User.UserAllRecupers.OrderByDescending(v => v.EnHospDay))
                {
                    var bbr = (i % 3) == 2;
                    i++;

                    if (rec.DepartmentID == SiteUser.DepartmentID || ViewBag.Flag == "Recuper")
                    {
                    @Ajax.ActionLink(rec.EnHospDay.ToString("yy年M月") + "-" + rec.Hospital.HospCode, "RecuperEnHospEdit", new { ID = rec.RecuperID }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "dialogbox", Confirm = "" }, new { id = "rid" + rec.RecuperID })
                    }
                    else
                    {
                    <a href="#" style="color: #aaaaaa;">@(rec.EnHospDay.ToString("yy年M月") + "-" + rec.Hospital.HospCode)</a>
                    }

                    if (bbr)
                    { 
                    <br />
                    }
                }
            </td>
            @if (ViewBag.Flag != "Recuper")
            {
                <td align="right" width="88" nowrap="nowrap" valign="top">
                    @if (SiteUser.IsDoctorDepManager && Model.User.UserId != Guid.Empty)
                    {
                        @Ajax.ActionLink("+录入住院信息", "RecuperEnHospEdit", new { ID = string.Empty, UserID = Model.User.UserId }, new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "dialogbox", Confirm = "" })
                    }
                </td>
            }
        </tr>
    </table>
    <fieldset>
        @Html.HiddenFor(model => model.UserID)
        @Html.HiddenFor(model => model.RecuperID)
        <table class="width noborder thistable tiny" cellpadding="0" cellspacing="0" style="padding-top: 0px; padding-bottom: 0px;">
            <col width="15%" />
            <col width="15%" />
            <col width="35%" />
            <col width="35%" />
            <tr>
                <td colspan="2">@Html.EditorFor(model => model.Hospital.HospName, "TxtFieldRO")
                    @Html.HiddenFor(model => model.HospitalID)
                    @Html.HiddenFor(model => model.BingQuID)
                    @Html.HiddenFor(model => model.DepartmentID)
                </td>
                <td>
                    @Html.EditorFor(model => model.BingQu.Title, "TxtFieldRO")
                </td>
                <td>
                    @Html.EditorFor(model => model.Department.DepName, "TxtFieldRO")
                </td>
            </tr>
            <tr>
                <td colspan="2">@Html.EditorFor(model => model.EnHospDay, "TxtField")
                </td>
                <td>
                    @Html.EditorFor(model => model.DeHospDay, "DehospTimeTxtField")
                </td>
                <td>@Html.EditorFor(model => model.BingAnHao, "TxtField")
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <div class="editor-label">
                        <span style="color: Red">*</span>
                        @Html.Label("主管医生")
                    </div>
                    @if (ViewBag.Flag == "Recuper")
                    {
                        //@Html.EditorFor(model => model.Doctor.UserName, "TxtField")                        
                        <div class="editor-field">
                            @Html.TextBoxFor(model => model.Doctor.UserName)
                            @Html.ValidationMessageFor(model => model)
                        </div>
                    }
                    else
                    {
                        <div class="editor-field">
                            @{
                        var users = ViewBag.Users as IEnumerable<aspnet_Users>;
                        var defaultdoctor = Model.DoctorID == Guid.Empty ? users.First().UserId : Model.DoctorID;
                            }
                            @Html.DropDownListFor(model => model.DoctorID, new SelectList(ViewBag.Users, "UserID", "UserName", defaultdoctor))
                        </div>
                    }
                </td>
                <td>
                    @Html.EditorFor(model => model.ZhuYuanYiSheng, "TxtField", new { FieldTitle = "手术日期", ForceDate = true })
                </td>
                <td></td>
            </tr>
            <tr>
                <td colspan="4" class="big-input">
                    @Html.EditorFor(model => model.SuiFangLeiXing, "TxtField")
                </td>
            </tr>
            <tr>
                <td colspan="4">
                    <table class="width noborder">
                        <tr class="">
                            <td>出院诊断：<a title="" href="#" onclick="$('#treeselector').load('@(Url.Action("ZhenDuanFenLei"))',{'CV':$('#ts_SrcZD').val()},function(){showDialogEx('#treeselector','请选择',true);});return false;">添加...</a>
                                <br />
                                @Html.TextAreaFor(model => model.ZhenDuanS, new { rows = 3, cols = 35, id = "ts_SrcZD" })
                            </td>
                            <td>手术名称：<a title="" href="#" onclick="$('#treeselector').load('@(Url.Action("ShouShuFenLei"))',{'CV':$('#ts_SrcSS').val()},function(){showDialogEx('#treeselector','请选择',true);});return false;">添加...</a>
                                <br />
                                @Html.TextAreaFor(model => model.ShouShuS, new { rows = 3, cols = 35, id = "ts_SrcSS" })
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="4" class="big-input">特殊医用耗材：<a title="" href="#" onclick="$('#treeselector').load('@(Url.Action("BeiJianFenLei"))',{'CV':$('#ts_SrcBJ').val()},function(){showDialogEx('#treeselector','请选择',true);});return false;">添加...</a>
                    <br />
                    @Html.TextAreaFor(model => model.BeiZhu, new { rows = 2, cols = 80, id = "ts_SrcBJ" })
                </td>
            </tr>
        </table>
        @if (ViewBag.Flag != "Recuper")
        {
            <div id="accordion">
                <h3>定制信息</h3>
                <div id="AttachInfoContainer">
                    @Html.Action("RecuperAttachInfoPartial", new { type = "EnHospital", recuperId = Model.RecuperID })
                </div>
            </div>
        }
        <p>
            <div style="float: left; width: 30%">
                不发起随访：@Html.CheckBoxFor(model => model.GuoQi) <a onclick="alert('将本次住院标记为不发起随访，对应的随访发起情况都将会自动取消发起，请谨慎使用！'); return false;"
                    href="#" class="error">重要提示...</a>
            </div>
            <div style="float: right; width: 30%">
                @if (ViewBag._ReadOnly == true)
                {
                    <input type="button" disabled="disabled" value="确定" />
                }
                else if (SiteUser.IsDoctorDepManager)
                {
                    <input type="submit" value="确定" />
                }
            </div>
        </p>
    </fieldset>
}
<div id="treeselector">
</div>
@if (ViewBag.Flag == "Recuper")
{
    <script type="text/javascript">
        $.dialogReady(function () {
            $("input").attr("disabled", true);
            $("textarea").attr("disabled", true);
        });
    </script>
}
@{
    var sflxs = string.Empty;
    if (SiteUser.MainRoleName == "Doctor")
    {
        sflxs = "'" + string.Join("','", SiteUser.Department.DepartmentProfiles.Where(v => v.SettingKey.Equals("SuiFangLeiXing", StringComparison.OrdinalIgnoreCase)).Select(v => v.SettingValue).Distinct().ToArray()) + "'";
    }
    else
    {
        sflxs = "'" + string.Join("','", Model.Department.DepartmentProfiles.Where(v => v.SettingKey.Equals("SuiFangLeiXing", StringComparison.OrdinalIgnoreCase)).Select(v => v.SettingValue).Distinct().ToArray()) + "'";
    }
            //SiteUser.Department.DepartmentProfiles.Where(v => v.SettingKey == "SuiFangLeiXing").Select(v => v.SettingValue).Distinct().ToArray();   
            //var sflxs = "'" + string.Join("','", SiteUser.Department.QizSubjects.Where(v => v.StatusID == "100" && v.SubjectType != "指标库").Select(v => v.Title).Distinct().ToArray()) + "'";
    
}
<script type="text/javascript">
    $.dialogReady(function () {

        $("#rid@(Model.RecuperID)").css("background-color", "red");
        $("#SuiFangLeiXing").select2({ tags: [ @Html.Raw(sflxs)] });
        $('#AttachInfoContainer textarea').attr({ 'rows': 3, 'cols': 78 });

        $("#accordion").accordion({
            collapsible: true,
            active: false
        });
    });
</script>
